import axios from "axios";

const instance = axios.create({
    baseURL: 'http://www.api.ewshop.cn/admin/',
    timeout: 5000
})

export function get(url, params) {
    return instance.get(url, {
        params
    })
}

export function post(url, params) {
    return instance.post(url, params, {
        transformRequest: [
            function(data) {
                let str = '';
                for (let key in data) {
                    str += encodeURIComponent(key) + '=' +encodeURIComponent(data[key]) + '&';
                }
            
                console.log(str);
                return str;
            
            }
        ],
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        }
    })
}